/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.heyma.webapp;

import org.heyma.webapp.model.Persona;
import org.heyma.webapp.srv.IPersonaSrv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * @author John
 */
@Controller
public class MainController {

    @Autowired
    private IPersonaSrv service;

    @RequestMapping("/saludo.htm")
    public @ResponseBody
    String saludo() {
        return "Hola mundo";
    }

    @RequestMapping("/registerpage.htm")
    public String registerPage() {
        return "registerPage"; //hace referencia a WEB-INF/jsp/registerPage.jsp
    }

    @RequestMapping(value = "/guardarpersona.htm", method = RequestMethod.POST)
    public String guardarPersona(Persona persona) {
        service.guardarPersona(persona);
        return "successPage"; //hace referencia a WEB-INF/jsp/successPage.jsp
    }
}
